from . import db
from datetime import datetime

class EtfFund(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64))
    code = db.Column(db.String(16))
    close = db.Column(db.Float)
    rate = db.Column(db.Integer)
    premium = db.Column(db.Integer)
    tag = db.Column(db.String(128))
    mtexp = db.Column(db.String(32))
    fundfirm = db.Column(db.String(64))
    fundmanager = db.Column(db.String(64))
    listdate = db.Column(db.String(32))
    index = db.Column(db.String(128))
    avgamount = db.Column(db.Float)
    m1 = db.Column(db.Integer)
    y0 = db.Column(db.Integer)
    y1 = db.Column(db.Integer)
    y3 = db.Column(db.Integer)
    y5 = db.Column(db.Integer)
    scale = db.Column(db.Float)
    estabdate = db.Column(db.String(32))
    substart = db.Column(db.String(32))
    subend = db.Column(db.String(32))
    sevendays = db.Column(db.Float)
    updated_at = db.Column(db.DateTime, default=datetime.utcnow)

class LofFund(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64))
    code = db.Column(db.String(16))
    close = db.Column(db.Float)
    rate = db.Column(db.Integer)
    premium = db.Column(db.Integer)
    tag = db.Column(db.String(128))
    mtexp = db.Column(db.String(32))
    fundfirm = db.Column(db.String(64))
    fundmanager = db.Column(db.String(64))
    listdate = db.Column(db.String(32))
    index = db.Column(db.String(128))
    avgamount = db.Column(db.Float)
    m1 = db.Column(db.Integer)
    y0 = db.Column(db.Integer)
    y1 = db.Column(db.Integer)
    y3 = db.Column(db.Integer)
    y5 = db.Column(db.Integer)
    scale = db.Column(db.Float)
    estabdate = db.Column(db.String(32))
    substart = db.Column(db.String(32))
    subend = db.Column(db.String(32))
    sevendays = db.Column(db.Float)
    updated_at = db.Column(db.DateTime, default=datetime.utcnow)

class MoneyFund(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64))
    code = db.Column(db.String(16))
    close = db.Column(db.Float)
    rate = db.Column(db.Integer)
    tag = db.Column(db.String(128))
    mtexp = db.Column(db.String(32))
    fundfirm = db.Column(db.String(64))
    fundmanager = db.Column(db.String(64))
    listdate = db.Column(db.String(32))
    index = db.Column(db.String(128))
    avgamount = db.Column(db.Float)
    scale = db.Column(db.Float)
    sevendays = db.Column(db.Float)
    updated_at = db.Column(db.DateTime, default=datetime.utcnow)

class CollectLog(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    fund_type = db.Column(db.String(16))
    api_url = db.Column(db.String(256))
    status = db.Column(db.String(16))
    count = db.Column(db.Integer)
    error = db.Column(db.Text)
    created_at = db.Column(db.DateTime, default=datetime.utcnow)
